import socket, time, threading, uuid
# 开启ip和端口
ip_port = ('0.0.0.0', 9993)
# 生成一个socket对象
sk = socket.socket()
# 绑定ip端口
sk.bind(ip_port)
# 最多连接数
sk.listen(5)


def handle_conn(conn, addr):
    print("客户端地址:", str(addr))
    while True:
        client_data = conn.recv(1024)
        print(client_data.decode("utf-8"))
        conn.sendall(bytes("来自服务器的回复" + client_data.decode("utf-8"), "utf-8"))


while True:
    conn, addr = sk.accept()
    print('get new conn')
    t = threading.Thread(target=handle_conn, args=(conn, addr))
    t.start()





